package cc.fine.svc.main.service.impl.tbl;

import cc.fine.svc.main.bean.dto.VideoInfoDto;
import cc.fine.svc.main.bean.po.TblCollect;
import cc.fine.svc.main.mapper.TblCollectMapper;
import cc.fine.svc.main.service.tbl.TblCollectService;
import cc.fine.svc.main.service.tbl.TblVideoService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author wyihe
 * @since 2023-10-25
 */
@Service
public class TblCollectServiceImpl extends ServiceImpl<TblCollectMapper, TblCollect> implements TblCollectService {

    @Autowired
    private TblVideoService videoService;

    @Override
    public List<VideoInfoDto> getVideoList(String id) {
        // 获取收藏夹下的 videoId
        List<String> videoIds = getVideoIds(id);

        return videoService.getInfoBatch(videoIds);
    }

    private List<String> getVideoIds(String id) {
        List<String> res = baseMapper.getVideoIds(id);
        if (res == null) res = new ArrayList<>();
        return res;
    }
}
